package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;


import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.VendorSettlementDetail;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.VendorSettlementDetailMapper;
import com.ruoyi.system.service.IVendorSettlementDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * detailService业务层处理
 *
 * @author admin
 * @date 2023-12-17
 */
@Service
public class VendorSettlementDetailServiceImpl implements IVendorSettlementDetailService
{
    @Autowired
    private VendorSettlementDetailMapper vendorSettlementDetailMapper;

    /**
     * 查询detail
     *
     * @param id detailID
     * @return detail
     */
    @Override
    public VendorSettlementDetail selectVendorSettlementDetailById(Long id)
    {
        return vendorSettlementDetailMapper.selectVendorSettlementDetailById(id);
    }

    /**
     * 查询detail列表
     *
     * @param vendorSettlementDetail detail
     * @return detail
     */
    @Override
    public List<VendorSettlementDetail> selectVendorSettlementDetailList(VendorSettlementDetail vendorSettlementDetail)
    {
        return vendorSettlementDetailMapper.selectVendorSettlementDetailList(vendorSettlementDetail);
    }

    /**
     * 新增detail
     *
     * @param vendorSettlementDetail detail
     * @return 结果
     */
    @Override
    public int insertVendorSettlementDetail(VendorSettlementDetail vendorSettlementDetail)
    {
        if(StringUtils.isNull(vendorSettlementDetail)) {
            throw new BaseException("新增detail失败！");
        }
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        vendorSettlementDetail.setCreateBy(SecurityUtils.getNickName());
        vendorSettlementDetail.setCreateTime(new Date());
        return vendorSettlementDetailMapper.insertVendorSettlementDetail(vendorSettlementDetail);
    }

    /**
     * 修改detail
     *
     * @param vendorSettlementDetail detail
     * @return 结果
     */
    @Override
    public int updateVendorSettlementDetail(VendorSettlementDetail vendorSettlementDetail)
    {
        return vendorSettlementDetailMapper.updateVendorSettlementDetail(vendorSettlementDetail);
    }

    /**
     * 批量删除detail
     *
     * @param ids 需要删除的detailID
     * @return 结果
     */
    @Override
    public int deleteVendorSettlementDetailByIds(Long[] ids)
    {
        if(StringUtils.isNull(ids)){
            throw new BaseException("需要删除的detailID为空！");
        }
        return vendorSettlementDetailMapper.deleteVendorSettlementDetailByIds(ids);
    }

    /**
     * 删除detail信息
     *
     * @param id detailID
     * @return 结果
     */
    @Override
    public int deleteVendorSettlementDetailById(Long id)
    {
        if(StringUtils.isNull(id)){
            throw new BaseException("需要删除的detailID为空！");
        }
        return vendorSettlementDetailMapper.deleteVendorSettlementDetailById(id);
    }
}
